package com.dragon.concurrent.demo.readandwrite;

public class ReadWorker extends Thread {

    private final ShareData data;

    public ReadWorker(ShareData data) {
        this.data = data;
    }

    @Override
    public void run() {
        while (true) {
            try {
                System.out.println(Thread.currentThread().getName() + " reads " + String.valueOf(data.read()));
            } catch (InterruptedException e) {
                e.printStackTrace();
                break;
            }
        }
    }
}
